$(document).ready(function() {
	//ajaxform
	var options = { 
		beforeSubmit:showRequest,//表单验证方式
        success:showResponse  // post-submit callback 
    }; 

    $('#ajaxForm').ajaxForm(options); 

    function showResponse(responseText, statusText)  {
		if (statusText == 'success') {
			var responseText=eval('('+responseText+')');
			if(responseText.state == 'SUCCESS'){
				$(".successInfo").show();
				$("#ajaxForm").hide();				
			}else{
				$("#form-btn").removeAttr('disabled');
		 		$("#msg").html('<font style="color:#f00">'+responseText.state+'</font>');	
			}			
		}else{
			$("#form-btn").removeAttr('disabled');
		 	$("#msg").html('Lost Service');			
		}
	} 

	function showRequest(){
		 validata = $("form.form-validata").valid();
		 if (validata){
		 	$("#form-btn").attr('disabled','disabled');
		 	$("#msg").html('<img src="/tpl/Home/common/image/loadding.gif">');
		 }
		 return validata;
	}

	//validation验证
	$("form.form-validata").validate({
		errorElement: "p",
        errorClass: "error",
	})

});